<?php
/**
 * Created by b17
 * 2/29/12 8:17 PM
 */

namespace Managers\Widget;

class SubscribeWidget extends AbstractWidget
{
    public function init()
    {
        $this->view->isActive = !isset($_COOKIE['subscribe']);
        $this->view->form = $this->_getForm();

    }

    private function _getForm()
    {
        $formBuilder = \G4T\Form\FormBuilder::createFormBuilder(\Managers\Subscribers::TABLE, array('id' => 'subscribe-form'))
            ->addField('email', 'email', array('label' => 'Email', 'style'=>'width:170px'))
            ->addField('submit', 'submit', array('label' => 'Подписаться','class'=>'btn' ));
        return $formBuilder->getForm();
    }

    /**
     * Название файла для вывода.
     *
     */
    public function getScriptName()
    {
        return "/widget/subscribe.phtml";
    }
}
